<?php
namespace Common\Models;
use Common\BaseModel;
class Opercate extends BaseModel
{
	public $res;
	public $expire;
	public function getSource()
    {
        return "f_opercate";
    }


    //根据等级查找数据
    public function find_first($level_id){
        $conditions = "level_id =$level_id";
        $res_level = $this->findFirst(
            array(
                $conditions,
        ));
        if(!$res_level){
            $res_level = $this->findFirst(
                array(
                    "default =1",
            ));
        }
        if($res_level){
            $operator = new Operator();
            $res = $operator->get_list($res_level->id);
        }else{
            $res =[];
        }
        return $res;
    }



    //根据等级查找菜单和广告
    public function find_menu_ad($level_id,$user_info){
        $conditions = "level_id =$level_id";
        $res_level = $this->findFirst(
            array(
                $conditions,
            ));
        if(!$res_level){
            $res_level = $this->findFirst(
                array(
                    "default =1",
                ));
        }
        if($res_level){
            $opermenu = new OperMenu();
            $res=$opermenu->get_list($res_level->id,$user_info);
        }else{
            $res =[];
        }
        return $res;
    }

}
